package com.ss.android.article.base.ui;

import android.content.Intent;
import android.view.View;

import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.ss.android.article.base.feature.detail2.cc;
import com.ss.android.article.base.feature.detail2.DetailIntentCreator;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.newmedia.a.AdsAppBaseActivity;
import com.ss.android.newmedia.util.AppUtil;

import org.json.JSONException;
import org.json.JSONObject;

final class ay implements View.OnClickListener {
    private final ax a;

    ay(ax arg1) {
        this.a = arg1;

    }

    public final void onClick(View arg19) {
        JSONObject v10;
        int v13;
        long v16;
        long v14;
        Object v11;
        ax v12 = this.a;
        if (arg19 != null) {
            Object v3 = null;
            try {
                Object v2_1 = arg19.getTag();
                if ((v2_1 instanceof ax)) {
                    v11 = v2_1;
                } else {
                    v11 = v3;
                }

                if (v11 == null) {
                    return;
                }

                if (((ax) v11).r == null) {
                    return;
                }

                if (((ax) v11).r.groupId <= 0) {
                    return;
                }

                v14 = ((ax) v11).r.groupId;
                v16 = ((ax) v11).r.itemId;
                v13 = ((ax) v11).r.aggrType;
                ((ax) v11).r.clickTimestamp = System.currentTimeMillis();
                ((ax) v11).c.setSelected(false);
                if (((ax) v11).r.clickTimestamp > 0) {
                    ((ax) v11).c.setTextColor(v12.u.getColorStateList(com.ss.android.article.browser.R.color.c1));
                }

                if (v12.C <= 0) {

                } else {
                    try {
                        new JSONObject().put("from_gid", v12.C);
                    } catch (JSONException v2_2) {
                    }
                }
                String v2_3 = ((ax) v11).r.outerSchema;
                if (!android.support.design.a.isTextEmpty(v2_3) && (AppUtil.b(v12.s, "com.youku.phone", v2_3))) {
                    AppUtil.b(v12.s, v2_3);
                    MobClickCombiner.onEvent(v12.s, "detail", "enter_youku");
                    return;
                }

                if (v12.r.videoSubjectId <= 0) {
                    MobClickCombiner.onEvent(v12.s, "video", "click_album", v12.r.groupId, ((long) v12.D));
                } else {
                    v10 = new JSONObject();
                    try {
                        v10.put("video_subject_id", v12.r.videoSubjectId);
                        MobClickCombiner.onEvent(v12.s, "video", "click_album", v12.r.groupId, ((long) v12.D), v10);
                    } catch (JSONException v2_2) {
                    }
                }

                label_78:
                if (((v12.s instanceof cc)) && ((cc) v12.s).a(v12.r, 1)) {
                    return;
                }

                if (!android.support.design.a.isTextEmpty(v12.r.openPageUrl)) {
                    AppUtil.b(v12.s, AdsAppBaseActivity.b(((ax) v11).r.openPageUrl));
                    return;
                }

                if (!android.support.design.a.isTextEmpty(v12.r.openUrl)) {
                    AppUtil.b(v12.s, AdsAppBaseActivity.b(((ax) v11).r.openUrl));
                    return;
                }

                Intent v3_1 = new Intent();
                v3_1.putExtra("view_single_id", true);
                v3_1.putExtra("group_id", v14);
                v3_1.putExtra("item_id", v16);
                v3_1.putExtra("aggr_type", v13);
                v3_1.putExtra("detail_source", "click_related");
                v3_1.putExtra("group_flags", ((ax) v11).r.groupFlags);
                if (v12.C > 0) {
                    v3_1.putExtra("from_gid", v12.C);
                }

                Intent v2_4 = android.support.design.a.b(((long) ((ax) v11).r.groupFlags)) ? ((DetailIntentCreator) ComponentsManifest.findComponent(DetailIntentCreator.class)).createNewVideoDetailIntent(v12.s, v3_1.getExtras()) : ((DetailIntentCreator) ComponentsManifest.findComponent(DetailIntentCreator.class)).createNewDetailIntent(v12.s, v3_1.getExtras());
                v12.s.startActivity(v2_4);
            } catch (Throwable v2) {
                v2.printStackTrace();
            }
        }
    }
}

